package com.itheima.handler;


import com.itheima.common.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    /**
     * 全局异常处理器
     * @param e
     * @return
     */
    @ExceptionHandler(RuntimeException.class)
    public Result exceptionHandler(Exception e) {
        log.error(e.getMessage());
        return Result.error(e.getMessage());
    }
}
